#!/bin/bash

build_id=`sudo hag csv platform_status  |grep "build id"`
build_id=`echo ${build_id##*:}`
hag csv pdh_cert_export
hag csv generate_policy -nodebug
hag csv generate_launch_blob -build $build_id -bios /opt/hygon/csv/OVMF.fd
tr -d '\n' < guest_owner_dh.cert > dh_cert.base64
tr -d '\n' < launch_blob.bin > session.base64
./pack-secret.py --passwd abc --build $build_id
base64 -w 0 secret.bin > secret.bin.b64
base64 -w 0 secret_header.bin > secret_header.bin.b64
qemu-system-x86_64 -enable-kvm -cpu host -smp 4 -m 4096 -drive if=pflash,format=raw,unit=0,file=/opt/hygon/csv/OVMF.fd,readonly=on  -hda /opt/hygon/csv/ubuntu.qcow2 -object sev-guest,id=sev0,policy=0x1,cbitpos=47,reduced-phys-bits=5,dh-cert-file=dh_cert.base64,session-file=session.base64,secret-header-file=./secret_header.bin.b64,secret-file=./secret.bin.b64 -machine memory-encryption=sev0 -name test -vnc 0.0.0.0:1
